package Code;

public class EnemyTank {

	//fields derived from https://facwiki.cs.byu.edu/cs470sp11/index.php/BZRC_Protocol#mytanks
	private int id;
	private String callsign;
	private String status;
	private Team team;
	private Team flag;
	private double x;
	private double y;
	private double angle;
	
	public EnemyTank() {
		
	}
	
	public EnemyTank(String[] attrs) {
		this.setCallsign(attrs[1]);
		this.setTeam(attrs[2]);
		this.setStatus(attrs[3]);
		this.setFlag(attrs[4]);
		this.setX(Double.parseDouble(attrs[5]));
		this.setY(Double.parseDouble(attrs[6]));
		this.setAngle(Double.parseDouble(attrs[7]));
	}
	
	private void setTeam(String team) {
		if(team.equalsIgnoreCase("-")) {
			this.team = Team.NONE;
		} else {
			this.team = Team.valueOf(team.toUpperCase());
		}
	}

	public Point getLocation() {
		return new Point(this.getX(), this.getY());
	}
	
	public void setLocation(final Point point) {
		this.setX(point.getX());
		this.setY(point.getY());
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getCallsign() {
		return callsign;
	}
	public void setCallsign(String callsign) {
		this.callsign = callsign;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}

	public Team getFlag() {
		return flag;
	}
	public void setFlag(Team flag) {
		this.flag = flag;
	}
	public void setFlag(String flag) {
		if(flag.equalsIgnoreCase("-")) {
			this.flag = Team.NONE;
		} else {
			this.flag = Team.valueOf(flag.toUpperCase());
		}
	}
	public boolean hasFlag() {
		return flag != Team.NONE;
	}
	public double getX() {
		return x;
	}
	public void setX(double d) {
		this.x = d;
	}
	public double getY() {
		return y;
	}
	public void setY(double d) {
		this.y = d;
	}
	public double getAngle() {
		return angle;
	}
	public void setAngle(double angel) {
		this.angle = angel;
	}

	public Team getTeam() {
		return team;
	}

	public void setTeam(Team team) {
		this.team = team;
	}
	
}
